<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/3.0.2/vue.global.js"></script>
</head>
<body>
    <div id="app"></div>
</body>
<script>
    
    const app = Vue.createApp({
        data(){
            return{
                name:'bbbccc'
            }
        },
        methods:{

        },
        template:`<Son :name="name"/>`
        
    })
    app.component('Son',{
        // 接收父组件传值并进行校验
        props:{
            name:{
                // 类型校验
                type: String,
                // 是否必填
                required:true,
                // 精准校验
                validator:function(value){
                    return value.search("aaa") != -1
                },
                // 默认值
                default: 'aaabbb'
            }
        }
        ,template:'<div>{{name}}</div>'
    })
    app.mount("#app")
</script>
</html>